﻿#region Usings

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Rail.Net.Common;
using Rail.Net.Common.ActionFilters;
using Rail.Net.Common.Helpers;
using Rail.Net.Common.Resources;
using Rail.Net.Core.Model.Nonpersistent;

#endregion

namespace Rail.Net.Controllers
{
    [SetCulture]
    public class DetailsController : Controller
    {
        public ActionResult Details(int id, bool forwardDirection)
        {
            try
            {
                var cookieName = forwardDirection ? Constants.FromProductOffersCookie : Constants.ToProductOffersCookie;
                var productOfferModel = Session[cookieName] as ProductOfferModel;
                if (productOfferModel != null)
                {
                    var productModel = productOfferModel.Products.SingleOrDefault(c => c.Index == id);
                    return PartialView("Details", productModel);
                }
            }
            catch (Exception e)
            {
                return Content(e.Message);
            }
            return Content(Global.Main_SessionTimeout);
        }
    }
}